package com.example.paging3samples.database

import androidx.paging.PagingSource
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.example.paging3samples.database.model.PostEntity

/**
 * author: LiLiang
 * createTime: 2022/9/15-12:37
 * remark:
 **/

@Dao
interface PostDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertPosts(postEntity: List<PostEntity>)

    @Query("DELETE FROM postEntity")
    suspend fun removePostAll()

    @Query("SELECT * FROM postEntity")
    fun getPosts(): PagingSource<Int, PostEntity>


}